package Main;

import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JOptionPane;

import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureIO;


public class ItemGame {
	public Texture m_Tex;
	public float PosX,PosY,PosZ;
	public int PosXMatrix,PosYMatrix,PosZMatrix;
	public int ID;
	public Point3D m_trans;
	public Point3D m_scale;
	public Point3D m_RoXYZ;
	public float m_rotation;
	public Boolean m_TestColision;
	
	public ItemGame(int _ID,Point3D _trans,Point3D _scale,Point3D _RoXYZ,float _rotation,String _path)
	{
		m_TestColision=false;
		ID=_ID;
		m_trans=_trans;
		m_scale=_scale;
		m_RoXYZ=_RoXYZ;
		m_rotation=_rotation;
		m_Tex = LoadTexture(_path);
		m_Tex.enable();
		
	}
	public ItemGame()
	{
		m_TestColision=false;
		ID=0;
		m_trans=new Point3D(0,0,0);
		m_scale=new Point3D(0,0,0);
		m_RoXYZ=new Point3D(0,0,0);
		m_rotation=0;
	}
	public void Init(String _path)
	{
		m_Tex = LoadTexture(_path);
		m_Tex.enable();

	}

	public Texture LoadTexture(String _path){
		Texture _result;
		BufferedImage image;
		try{
			image = ImageIO.read(this.getClass().getResource(_path));
			_result = TextureIO.newTexture(image,false);
		}catch(IllegalArgumentException e){
			JOptionPane.showMessageDialog(null, "Can not load file \"" + _path + "\". The application will be exit !"+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
			//System.exit(0);
			return null;
		}catch(IOException e){
			e.printStackTrace();
			return null;
		}
		return _result;
		
	}
}
